home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / bbs / doorinfo.zip / LMTCA.ASM < prev    next >
Assembly Source File  |  1997-05-14  |  9KB  |  451 lines

  1. ;
  2. ; assembly language functions for C programs to use the
  3. ; multi-tasking features of Cswitch
  4. ;
  5. ; If you are using these functions with BORLAND compilers,
  6. ; be sure to specify the /ml switch to TASM so that the
  7. ; function names do not get converted to upper case
  8. ;
  9.  
  10. p1 = 6
  11. p2 = 8
  12. p3 = 10
  13. p4 = 12
  14.  
  15. ;
  16. ; cswitch INT62 functions
  17. ;
  18. ; 1  = relinqush rest of our time slice
  19. ; 2  = wait for semaphore
  20. ; 3  = check semaphore
  21. ; 4  = trigger semaphore
  22. ; 5  = delay
  23. ; 6  = suspend
  24. ; 7  = spawn
  25. ; 8  = wake up a task
  26. ; 10 = test message queue
  27. ; 11 = send message
  28. ; 12 = read message
  29. ; 13 = don't allow task to be swapped out
  30. ; 14 = allow swapping again
  31. ; 15 = load and run a program from disk
  32. ; 16 = terminate a spawned program
  33. ; 17 = get tcb information
  34. ; 18 = get tcb address
  35. ; 19 = check status of previous load_task call
  36. ; 20 = send message to a pipe
  37. ; 21 = receive message from a pipe
  38. ; 22 = load a pipe task
  39. ; 23 = exec (load a task to REPLACE current task);
  40. ; 24 = see how many bytes are in a pipe
  41. ; 26 - read a message queue - no waiting
  42.  
  43.  
  44. mt_cint_text    segment word public 'CODE'
  45.         assume  cs:mt_cint_text
  46.  
  47.     public _relinq
  48.     public _spawn
  49.     public _loadtask
  50.     public _delay
  51.     public _send_md_msg
  52.     public _testmsg
  53.     public _recvmsg
  54.     public _recvmsg_nowait
  55.     public _sem_attach
  56.     public _sem_release
  57.     public _sem_test
  58.     public _setpri
  59.     public _suspend
  60.     public _wakeup
  61.     public _hog
  62.     public _nohog
  63.     public _spawn_exit
  64.     public _get_tcb_info
  65.     public _get_tcb_address
  66.     public _get_load_status
  67.     public _send_pipe
  68.     public _recv_pipe
  69.     public _loadpipe
  70.     public _execprog
  71.     public _test_pipe
  72.  
  73. _relinq  proc    far
  74.     mov ah,1
  75.     int 62h
  76.     ret
  77. _relinq endp
  78.  
  79.  
  80. _get_load_status  proc    far
  81.     mov ah,19
  82.     int 62h
  83.     ret
  84. _get_load_status endp
  85.  
  86. _spawn_exit proc far
  87.     mov ah,16
  88.     int 62h
  89.     ret
  90. _spawn_exit endp
  91.  
  92. _hog  proc    far
  93.     mov ah,13
  94.     int 62h
  95.     ret
  96. _hog endp
  97.  
  98. _nohog  proc    far
  99.     mov ah,14
  100.     int 62h
  101.     ret
  102. _nohog endp
  103.  
  104. _spawn  proc    far
  105.     push    bp
  106.     mov     bp,sp
  107.     push    bx
  108.     push    cx
  109.     push    dx
  110.     mov     bx,[bp+6]   ;offset
  111.     mov     dx,[bp+8]   ;segment
  112.     mov     cx,[bp+10]
  113.     mov     ah,7
  114.     int     62h
  115.     pop     dx
  116.     pop     cx
  117.     pop     bx
  118.     pop     bp
  119.     ret
  120. _spawn  endp
  121.  
  122. _get_tcb_info  proc    far
  123.     push    bp
  124.     mov     bp,sp
  125.     push    es
  126.     push    bx
  127.     mov     bx,[bp+6]   ;offset
  128.     mov     ax,[bp+8]   ;segment
  129.     mov     es,ax
  130.     mov     ah,17
  131.     int     62h
  132.     pop     bx
  133.     pop     es
  134.     pop     bp
  135.     ret
  136. _get_tcb_info  endp
  137.  
  138. _get_tcb_address  proc    far
  139.     push    bp
  140.     mov     bp,sp
  141.     push    es
  142.     push    bx
  143.     mov     bx,[bp+6]   ;offset
  144.     mov     ax,[bp+8]   ;segment
  145.     mov     es,ax
  146.     mov     ah,18
  147.     int     62h
  148.     pop     bx
  149.     pop     es
  150.     pop     bp
  151.     ret
  152. _get_tcb_address  endp
  153.  
  154. _loadtask  proc    far
  155.     push    bp
  156.     mov     bp,sp
  157.     push    es
  158.     push    bx
  159.     push    cx
  160.     push    dx
  161.     mov     bx,[bp+6]   ;offset of command line
  162.     mov     ax,[bp+8]   ;segment
  163.     mov     es,ax
  164.     mov     cx,[bp+10]  ;priority
  165.     mov     dx,[bp+12]  ;background flag - if non-0, allows loading to ems
  166.     mov     ah,15
  167.     int     62h
  168.     pop     dx
  169.     pop     cx
  170.     pop     bx
  171.     pop     es
  172.     pop     bp
  173.     ret
  174. _loadtask  endp
  175.  
  176. _loadpipe  proc    far
  177.     push    bp
  178.     mov     bp,sp
  179.     push    es
  180.     push    bx
  181.     push    cx
  182.     push    dx
  183.     mov     bx,[bp+6]   ;offset of command line
  184.     mov     ax,[bp+8]   ;segment
  185.     mov     es,ax
  186.     mov     cx,[bp+10]  ;priority
  187.     mov     dx,[bp+12]  ;background flag - if non-0, allows loading to ems
  188.     mov     ah,22
  189.     int     62h
  190.     pop     dx
  191.     pop     cx
  192.     pop     bx
  193.     pop     es
  194.     pop     bp
  195.     ret
  196. _loadpipe  endp
  197.  
  198. ; params = how many ticks
  199. _delay  proc    far
  200.     push    bp
  201.     mov     bp,sp
  202.     push    bx
  203.     mov     bx,[bp+6]
  204.     mov     ah,5
  205.     int     62h
  206.     pop     bx
  207.     pop     bp
  208.     ret
  209. _delay   endp
  210.  
  211.  
  212. _suspend  proc    far
  213.     mov     ah,6
  214.     int     62h
  215.     ret
  216. _suspend   endp
  217.  
  218. ;params = task to wake up
  219. _wakeup  proc    far
  220.     push    bp
  221.     mov     bp,sp
  222.     push    bx
  223.     mov     bx,[bp+6]
  224.     mov     ah,8
  225.     int     62h
  226.     pop     bx
  227.     pop     bp
  228.     ret
  229. _wakeup   endp
  230.  
  231.  
  232. ; params = new priority
  233. _setpri  proc    far
  234.     push    bp
  235.     mov     bp,sp
  236.     push    bx
  237.     mov     bx,[bp+6]
  238.     mov     ah,9
  239.     int     62h
  240.     pop     bx
  241.     pop     bp
  242.     ret
  243. _setpri   endp
  244.  
  245. _sem_attach    proc far
  246.     push    bp
  247.     mov     bp,sp
  248.     push    dx
  249.     mov     dx,[bp+6]
  250.     mov     ah,2
  251.     int     62h
  252.     pop     dx
  253.     pop     bp
  254.     ret
  255. _sem_attach    endp
  256.  
  257. _sem_test    proc far
  258.     push    bp
  259.     mov     bp,sp
  260.     push    dx
  261.     mov     dx,[bp+6]
  262.     mov     ah,3
  263.     int     62h
  264.     pop     dx
  265.     pop     bp
  266.     ret
  267. _sem_test    endp
  268.  
  269. _sem_release    proc far
  270.     push    bp
  271.     mov     bp,sp
  272.     push    dx
  273.     mov     dx,[bp+6]
  274.     mov     ah,4
  275.     int     62h
  276.     pop     dx
  277.     pop     bp
  278.     ret
  279. _sem_release    endp
  280.  
  281. _testmsg  proc far
  282.     push    bp
  283.     mov     bp,sp
  284.     push    dx
  285.     mov     dx,[bp+6]   ;queue number to check
  286.     mov     ah,10
  287.     int     62h
  288.     pop     dx
  289.     pop     bp
  290.     ret
  291. _testmsg      endp
  292.  
  293. _send_md_msg    proc far
  294.     push    bp
  295.     mov     bp,sp
  296.     push    dx
  297.     push    ds
  298.     push    si
  299.     push    cx
  300.     mov     si,[bp+8]  ;offset for data buffer
  301.     mov     ax,[bp+10]   ;segment for data buffer
  302.     mov     ds,ax
  303.     mov     cx,[bp+12]  ;length
  304.     mov     dx,[bp+6]   ;queue number to read from
  305.     mov     ah,11
  306.     int     62h
  307.     pop     cx
  308.     pop     si
  309.     pop     ds
  310.     pop     dx
  311.     pop     bp
  312.     ret
  313. _send_md_msg    endp
  314.  
  315. _recvmsg    proc far
  316.     push    bp
  317.     mov     bp,sp
  318.     push    dx
  319.     push    ds
  320.     push    si
  321.     push    cx
  322.     mov     si,[bp+8]  ;offset for data buffer
  323.     mov     ax,[bp+10]   ;segment for data buffer
  324.     mov     ds,ax
  325.     mov     cx,[bp+12]  ;length
  326.     mov     dx,[bp+6]   ;queue number to read from
  327. read2:
  328.     mov     ah,12
  329.     int     62h
  330.     cmp     ax,0fffeh   ;if -2 (0fffeh) is returned, then we have been
  331.                         ;triggered by something arriving on queue, and we
  332.                         ;must make the 'read' call again to retrieve it
  333.     jz      read2
  334.     pop     cx
  335.     pop     si
  336.     pop     ds
  337.     pop     dx
  338.     pop     bp
  339.     ret
  340. _recvmsg    endp
  341.  
  342. _recvmsg_nowait    proc far
  343.     push    bp
  344.     mov     bp,sp
  345.     push    dx
  346.     push    ds
  347.     push    si
  348.     push    cx
  349.     mov     si,[bp+8]  ;offset for data buffer
  350.     mov     ax,[bp+10]   ;segment for data buffer
  351.     mov     ds,ax
  352.     mov     cx,[bp+12]  ;length
  353.     mov     dx,[bp+6]   ;queue number to read from
  354.     mov     ah,26
  355.     int     62h
  356.     pop     cx
  357.     pop     si
  358.     pop     ds
  359.     pop     dx
  360.     pop     bp
  361.     ret
  362. _recvmsg_nowait    endp
  363.  
  364. _send_pipe    proc far
  365.     push    bp
  366.     mov     bp,sp
  367.     push    dx
  368.     push    ds
  369.     push    bx
  370.     push    cx
  371.     mov     dx,[bp+8]   ;offset for data buffer
  372.     mov     ax,[bp+10]  ;segment for data buffer
  373.     mov     ds,ax
  374.     mov     cx,[bp+12]  ;length
  375.     mov     bx,[bp+6]   ;pipe number to read from
  376.     mov     ah,20
  377.     int     62h
  378.     pop     cx
  379.     pop     bx
  380.     pop     ds
  381.     pop     dx
  382.     pop     bp
  383.     ret
  384. _send_pipe    endp
  385.  
  386. _recv_pipe    proc far
  387.     push    bp
  388.     mov     bp,sp
  389.     push    dx
  390.     push    ds
  391.     push    bx
  392.     push    cx
  393.     mov     dx,[bp+8]  ;offset for data buffer
  394.     mov     ax,[bp+10]   ;segment for data buffer
  395.     mov     ds,ax
  396.     mov     cx,[bp+12]  ;length
  397.     mov     bx,[bp+6]   ;queue number to read from
  398.     mov     ah,21
  399.     int     62h
  400.     pop     cx
  401.     pop     bx
  402.     pop     ds
  403.     pop     dx
  404.     pop     bp
  405.     ret
  406. _recv_pipe    endp
  407.  
  408. _test_pipe  proc far
  409.     push    bp
  410.     mov     bp,sp
  411.     push    bx
  412.     mov     bx,[bp+6]   ;pipe number, or -1 for our redirected I/O
  413.     mov     ah,24
  414.     int     62h
  415.     pop     bx
  416.     pop     bp
  417.     ret
  418. _test_pipe   endp
  419.  
  420. ;
  421. ; execprog loads a new task to completely REPLACE the current task.
  422. ; it inherits the current tasks pipe, if open, and will take over the
  423. ; current tasks tcb, if successful.
  424. ; if successful, the calling task does not return.
  425. ;
  426. _execprog    proc far
  427.     push    bp
  428.     mov     bp,sp
  429.     push    es
  430.     push    bx
  431.     push    cx
  432.     push    dx
  433.     mov     bx,[bp+6]   ;offset of command line
  434.     mov     ax,[bp+8]   ;segment
  435.     mov     es,ax
  436.     mov     cx,[bp+10]  ;priority
  437.     mov     dx,[bp+12]  ;background flag - if non-0, allows loading to ems
  438.     mov     ah,23
  439.     int     62h
  440.     pop     dx
  441.     pop     cx
  442.     pop     bx
  443.     pop     es
  444.     pop     bp
  445.     ret
  446. _execprog    endp
  447.  
  448. mt_cint_text    ends
  449.         end
  450.     
  451.